﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace BioCyber_Infection.Class
{
    abstract class Sprite
    {
        #region Begin of Declaration

        protected Texture2D imagem;
        protected float escala;
        protected float camada;
        protected float rotacao;
        protected Rectangle retanguloColisao;
        protected Color overlayColor;
        protected Vector2 pivo;
        public Vector2 posicao;
        public Vector2 Posicao
        {
            get
            {
                return posicao;
            }
            set
            {
                posicao = value;
            }
        }
        protected Rectangle colisao;
        public Rectangle Colisao
        {
            get
            {
                return colisao;
            }
            set
            {
                colisao = value;
            }
        }
        protected Rectangle destino;
        protected Vector2 origem;
        public bool visivel;
        protected bool direita;
        protected GameWindow Window;
        public struct animacao
        {
            public int quadro_X;
            public int quadro_Y;
            public int qtd_quadros;
            public int quadros_seg;
            public int Y;
            public string nome;
        }

        #endregion

        #region Sprite Methods

        public Sprite(Texture2D imagem, GameWindow Window)
        {
            this.imagem = imagem;
            this.Window = Window;
            this.visivel = true;
            //this.alfa = 1;
        }

        public abstract void Update(GameTime gameTime);

        public void Draw(GameTime gameTime, SpriteBatch spriteBatch, animacao _animacao)
        {
            if (visivel)
            {
                int frame = (int)(gameTime.TotalGameTime.TotalSeconds*_animacao.quadros_seg)%_animacao.qtd_quadros;
            
                spriteBatch.Draw(
                    imagem,
                    new Rectangle(
                        (int)posicao.X,
                        (int)posicao.Y,
                        _animacao.quadro_X,
                        _animacao.quadro_Y),
                    new Rectangle(
                        frame* _animacao.quadro_X,
                        _animacao.Y,
                        _animacao.quadro_X,
                        _animacao.quadro_Y),
                    Color.White,
                    rotacao,
                    pivo,
                    (direita) ? SpriteEffects.None : SpriteEffects.FlipHorizontally,
                    camada);
            }
        }

        #endregion
    }
}
